import request from '../utils/request';

// 根据条件获取课程(带分页)
export const getCourseByCondition = (data) => {
  return request.post(`/project/course/getCourseByCondition`, {
    data: {
      ...data,
      enable: true,
    },
  });
};

/**
 * 根据课程ID查询课程
 * objectId: 课程id
 */
export const getCourseDetails = (params) => {
  return request.get(`/project/course/getCourseById`, { params });
};

/**
 * 获取审核通过的课程评论-分页
 */
export const getCourseComment = (data) => {
  return request.post(`/project/course/getCourseCommentByCondition`, { data });
};

/**
 * 根据课程ID查询相关课程和相关专题
 * objectId: 课程id
 */
export const getRelatedCourseTopic = (params) => {
  return request.get(`/project/course/getRelatedCourseTopic`, { params });
};

/**
 * 课程评论
 */
export const addCourseComment = (data) => {
  return request.post(`/project/course/addCourseComment`, { data });
};

/**
 * 获取点赞数
 */
export const getLikesCountById = (params) => {
  return request.get(`/project/likes/getLikesCountById`, { params });
};

/**
 * 查询当前用户是否点赞--未登录返回false
 */
export const getVoteStatusById = (params) => {
  return request.get(`/project/likes/getVoteStatusById`, { params });
};

/**
 * 取消点赞
 */
export const unVoteCourse = (params) => {
  return request.post(`/project/likes/unVoteCourse`, { params });
};

/**
 * 点赞
 */
export const voteCourse = (params) => {
  return request.post(`/project/likes/voteCourse`, { params });
};

/**
 * 查询当前用户是否收藏--未收藏返回false
 */
export const getFavStatusById = (params) => {
  return request.get(`/project/fav/getFavStatusById`, { params });
};

/**
 * 收藏课程
 */
export const favCourse = (params) => {
  return request.post(`/project/fav/favCourse`, { params });
};

/**
 * 取消收藏课程
 */
export const unFavCourse = (params) => {
  return request.post(`/project/fav/unFavCourse`, { params });
};

/**
 * 更新课程学习进度
 */
export const updateMyJoinedCourse = (data) => {
  return request.post(`/project/user/updateMyJoinedCourse`, { data });
};

/**
 * 查询课程学习进度
 */
export const getLearnedByCourseId = (params) => {
  return request.get(`/project/user/getLearnedByCourseId`, { params });
};
